package com.study.decorator.general;

/**
 * 装饰器模式
 * 给定一个基础类 对基础类进行功能扩展
 * 可用通过不同的装饰类 自定义加减功能
 * 完全遵守开闭原则
 */
public class Test {
    public static void main(String[] args) {

        Component c1 = new ConcreteComponent();
        Decorator decoratorA = new ConcreteDecoratorA(c1);
        decoratorA.operation();
        Decorator decoratorB = new ConcreteDecoratorB(c1);
        decoratorB.operation();

        Decorator decoratorC = new ConcreteDecoratorB(decoratorA);
        decoratorC.operation();

    }
}
